package com.jinhongone.pattern.behavior.interpret;

/**
 * @author jinho
 * @className Variable
 * @description 终结表达式角色（具体数值的标识） -表达文法规则
 * @date 2025/4/21 10:28
 */
public class Variable extends AbstractExpression {

    private String name;

    public Variable(String name) {
        this.name = name;
    }

    @Override
    public int interpret(Context context) {
        //终结表达式解释逻辑：从环境类获取数值
        return context.getValue(this);
    }

    @Override
    public String toString() {
        return  name;
    }
}
